<template>
  <div class="edit_b_content">
    <ul class="info_list clearfix">
      <li >
        <b>您的姓名</b>
        <input type="text" maxlength="100" v-model="data.titleName" @input="inputAction"
        placeholder="请输入您的姓名"/>
      </li>
      <li>
        <b>联系电话</b>
        <input type="text" v-model="data.roleName" @input="inputAction" placeholder="请输入联系电话" class="input">
      </li>
      <li>
        <b>联系邮箱</b>
        <input type="text" v-model="data.emails" @input="inputAction" placeholder="请输入联系邮箱" class="input">
      </li>
      <li>
        <b>工作年限</b>
        <input type="text" v-model="data.years" @input="inputAction" placeholder="请输入工作年限" class="input">
      </li>
      <li >
        <b>学校</b>
        <input type="text" v-model="data.school" @input="inputAction" placeholder="请输入学校" class="input">
      </li>
      <li >
        <b>入职时间</b>
        <input type="text" v-model="data.entryTime" @input="inputAction" placeholder="请输入入职时间" class="input">
      </li>
      <li >
        <b>GIT地址</b>
        <input type="text" v-model="data.gitAddress" @input="inputAction" placeholder="请输入入职时间" class="input">
      </li>
    </ul>
  </div>
</template>
<script setup>
import { defineProps, defineEmits, reactive, watch } from 'vue';

const props = defineProps({
  id: String,
  initData: Object,
});

const emit = defineEmits(['work-input']);

const data = reactive({
  titleName: '',
  roleName: '',
  emails: '',
  years: '',
  school: '',
  entryTime: '',
  gitAddress: '',
});

const hasProperty = (obj, prop) => prop in obj;

watch(() => props.initData, (val) => {
  if (hasProperty(val, 'titleName')) {
    data.titleName = val.titleName || '';
    data.roleName = val.roleName || '';
    data.emails = val.emails || '';
    data.years = val.years || '';
    data.school = val.school || '';
    data.entryTime = val.entryTime || '';
    data.gitAddress = val.gitAddress || '';
  }
}, { immediate: true });

const inputAction = () => {
  emit('work-input', JSON.stringify(Object.assign(data, { type: 'basicInfo' })));
};


</script>
